package com.yx.robot.bean.robot;

import java.util.List;

public class Appointment<T extends CleanParam> {
    boolean isSwitch;
    int cleanMode = 0;  //清扫模式
    int workMode = 0; // 0x00扫拖 0x01仅扫 0x02仅拖
    int id;  //预约ID
    boolean enable;
    boolean AppointmentExpired = false;
    int time;  //以秒为单位  例如 7270 =  2*3600 + 1*60 + 10 即 02:01:10
    List<Integer> repeat;   // 可以 以一周为单位 例 {1,3,7} 表示周一,三,日
    T cleanParam;//自动清扫的参数  根据清扫类型设置不同的子类实现CleanParam RoomClean AreaClean PointClean

    /**
     * 生成id
     * 通过周期和时间拼接而成
     * @param time
     * @param week
     * @return
     */
    public static int genId(int time, List<Integer> week) {
        int id = 0;
        for (int i = 0; i < week.size(); i++) {
            id += Math.pow(2, week.get(i));
        }
        return id * 24 * 3600 + time;
    }

    /**
     * 初始化id 这个方法必须要在设置时间和周期后调用
     */
    public void initId() {
        setId(genId(time, repeat));
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getCleanMode() {
        return cleanMode;
    }

    public void setCleanMode(int cleanMode) {
        this.cleanMode = cleanMode;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public List<Integer> getRepeat() {
        return repeat;
    }

    public void setRepeat(List<Integer> repeat) {
        this.repeat = repeat;
    }

    public T getCleanParam() {
        return cleanParam;
    }

    public void setCleanParam(T cleanParam) {
        this.cleanParam = cleanParam;
    }

    public int getWorkMode() {
        return workMode;
    }

    public void setWorkMode(int workMode) {
        this.workMode = workMode;
    }

    public boolean isAppointmentExpired() {
        return AppointmentExpired;
    }

    public void setAppointmentExpired(boolean appointmentExpired) {
        AppointmentExpired = appointmentExpired;
    }

    public boolean isSwitch() {
        return isSwitch;
    }

    public void setSwitch(boolean aSwitch) {
        isSwitch = aSwitch;
    }
}
